package com.devilvan.betrice.lol.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.lol.dto.LolBattleTeamDto;
import com.devilvan.betrice.lol.po.LolBattleTeamPo;
import com.devilvan.betrice.lol.service.LolBattleTeamService;
import com.devilvan.betrice.lol.mapper.LolBattleTeamMapper;
import com.devilvan.betrice.lol.repository.LolBattleTeamRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description LOL-对局队伍信息 业务逻辑类
* @date 2022-09-30
*/
@Service
public class LolBattleTeamServiceImpl extends ServiceImpl<LolBattleTeamMapper, LolBattleTeamPo> implements LolBattleTeamService {
    @Resource(name = "lolBattleTeamRepository")
    private LolBattleTeamRepository lolBattleTeamRepository;

    @Override
    public LolBattleTeamPo saveUpdate(LolBattleTeamDto lolBattleTeamDto) {
        LolBattleTeamPo lolBattleTeamPo = new LolBattleTeamPo();
        UCopy.fullCopy(lolBattleTeamDto, lolBattleTeamPo);
        return lolBattleTeamRepository.saveAndFlush(lolBattleTeamPo);
    }

    @Override
    public List<LolBattleTeamPo> saveUpdateBatch(List<LolBattleTeamDto> list) {
        List<LolBattleTeamPo> lolBattleTeamPoList = UCopy.fullCopyCollections(list, LolBattleTeamPo.class);
        return lolBattleTeamRepository.saveAllAndFlush(lolBattleTeamPoList);
    }
}
